<extend name="Layout/index" />
<block name="breadcrumb-01">
	<li>
		<i class="icon-home home-icon"></i>
		<a href="#">首页</a>
	</li>
	<li class="active">首页管理</li>
</block>

<block name="breadcrumb-02">
	<h1>
		首页管理
		<small>
			<i class="icon-double-angle-right"></i>
			文件上传
		</small>
	</h1>
</block>
<block name='main'>
		<table class="table table-striped table-bordered table-hover">
			<thead>
			 <tr>
			 	<th>编号</th>
				<th>文件ID</th>
				<th>文件名</th>
				<th>文件路径</th>
				<th>操作</th>
			 </tr>
			</thead>
			<tbody>
			<volist name="data" id="vo" key="k">
				<tr>
					<td><{$k}></td>
					<td><{$vo.fileid}></td>
					<td><{$vo.filename}></td>
					<td>./Public/Home/Download/<{$vo.path}></td>
					<th>
						<input type="hidden" value="<{$vo.filename}>">
						<button value="<{$vo.fileid}>" type="button" class="Fedit btn btn-primary btn-xs" data-toggle="modal" data-target="#UpdateModal">编辑</button>
						<input type="hidden" value="<{$vo.path}>">
						<button value="<{$vo.fileid}>" type="button" class="Fedel btn btn-danger btn-xs">删除</button>
					</th>
				</tr>
			</volist>
			</tbody>
		</table>








		<!-- Button trigger modal -->
		<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
		  文件上传
		</button>

		<!-- Modal -->
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		  <div class="modal-dialog">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
		        <h4 class="modal-title" id="myModalLabel">文件上传</h4>
		      </div>
		      <div class="modal-body">
		      		<form action="<{:U('Mindex/FileAdd')}>" enctype="multipart/form-data" method="post">
					  <div class="form-group">
					    <label for="exampleInputPassword1">输入文件名称</label>
					    <input type="text" name="filename" class="form-control" id="name0" placeholder="请输入文件名称">
					  </div>
					  <div class="form-group">
					    <label for="exampleInputFile">选择文件</label>
					    <input type="file" name="file" id="exampleInputFile0">
					    <p class="help-block">请选择本地文件上传</p>
					  </div>
					<button type="submit" class="BtnSub btn btn-primary">提交</button>
					</form>
					
		      </div>
		    </div>
		  </div>
		</div>


		<!-- Modal -->
		<div class="modal fade" id="UpdateModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		  <div class="modal-dialog">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
		        <h4 class="modal-title" id="myModalLabel">文件修改</h4>
		      </div>
		      <div class="modal-body">
		      		<form action="<{:U('Mindex/FileUpdate')}>" enctype="multipart/form-data" method="post">
					  <div class="form-group">
					    <label for="exampleInputPassword1">更改文件名称</label>
					    <p class="help-block">您正在更改的是<span class="displayN" style="color:red;font-size:16px"></span>文件</p>
					    <input type="text" name="filename" class="form-control" id="name1" value="">
					  </div>
					  <div class="form-group">
					    <label for="exampleInputFile">选择文件</label>
					    <input type="file" name="file" id="exampleInputFile1">
					    <p class="help-block">请选择本地文件上传</p>
					  </div>
					 <input type="hidden" id="fileid" name="fileid" value="">
					 <input type="hidden" id="filePath" name="path" value="">
					<button type="submit" class="btn btn-primary">提交</button>
					</form>

		      </div>
		    </div>
		  </div>
		</div>









		<script type="text/javascript" src="__PUBLIC__/Admin/Js/jquery-2.1.4.min.js"></script>
		<script>
			$(function(){

				$('.Fedit').click(function(){
					var fileid = $(this).val();
					var path = $(this).next().val();
					var filename = $(this).prev().val();
					$('#fileid').val(fileid);
					$('#filePath').val(path);
					$('.displayN').html(filename);
				})

				$('.Fedel').click(function(){
					var fileid = $(this).val();
					var path = $(this).prev().val();
					var _this = $(this).parent('th').parent('tr');
					
					$.ajax({
						type:'GET',
						url:"<{:U('Mindex/FileDel')}>",
						data:{fileid:fileid,path:path},
						async:false,
						success:function(data){
							if(data == '1'){
								_this.hide();
							}
						},
					})
				})
			})
		</script>





</block>